package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import java.util.HashMap;

@Getter
@Setter
public class Order extends BaseDomain{

    public static final int STATE_DELIVERY = 0;//待付款
    public static final int STATE_SHIPPED= 1;//待收货
    public static final int STATE_COLLECT = 2;//已完成
    public static final int STATE_RECEIVED = 3;//已取消

    private Long orderNumber;//订单号
    private Long userId;//下单用户id

    @JsonFormat(pattern = "y-M-d hh:mm:ss" ,timezone="GMT+8")
    @DateTimeFormat(pattern = "y-M-d hh:mm:ss")
    private Date createTime;//创建时间
    private Integer status;//状态
    private String address;//地区
    private Integer cost;//花费
    private String name;//用户名
    private String phone;//电话


    public String getJson(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("userId",userId);
        map.put("status",status);
        map.put("address",address);
        map.put("name",name);
        map.put("phone",phone);
        map.put("cost",cost);
        return JSONUtil.toJSONString(map);
    }
    private List<OrderItem> orderItems = new ArrayList<>();
    private List<ShopCarItem> orderItem = new ArrayList<>();

}